<?php
class Korisnik_model extends CI_Model
{
	public function __construct()
	{
		parent::__construct();
	}
	
	public function prikaz_kategorii()
	{
		$query=$this->db->get('kategorija');
		return $query->result_array();
	}
	
	public function zemiKategorija($id)
	{
		$this->db->where(array('id'=>$id));
		$query=$this->db->get('kategorija');
		return $query->result_array();
	}
	
	//zemi gi site podkategorii za edna kategorija
	public function prikazPodkategorii($id)
	{
		$query = $this->db->get_where('podkategorija', array('konKategorija' => $id));
		return $query->result_array();
	}
	
	public function zemiPodkategorija($id)
	{
		$this->db->where(array('id'=>$id));
		$query=$this->db->get('podkategorija');
		return $query->result_array();
	}
	
	public function prikazNastani($id)
	{
		$query = $this->db->get_where('nastan', array('konPKategorija' => $id));
		return $query->result_array();
	}
	
	public function zemiNastan($id)
	{
		$this->db->where(array('id'=>$id));
		$query=$this->db->get('nastan');
		return $query->result_array();
	}
	
	public function zemiDatoteki($id)
	{
		$this->db->where(array('konNastan'=>$id));
		$query=$this->db->get('datoteki');
		return $query->result_array();
	}
	
	public function searchNastan($ime)
	{
		$this->db->select('*');
		$this->db->from('nastan');
		$this->db->like('ime', $ime, 'both');
		$query = $this->db->get();
		return $query->result_array();
	}
	
	public function searchDatoteka($ime)
	{
		$this->db->select('*');
		$this->db->from('nastan');
		$this->db->like('ime', $ime, 'both');
		$query = $this->db->get();
		return $query->result_array();
	}
	
	public function searchDatum($datum1, $datum2)
	{
		$this->db->select('*');
		$this->db->from('nastan');
		
		$array = array('data >' => $datum1, 'data <' => $datum2);
		
		$this->db->where($array);
		$query = $this->db->get();
		return $query->result_array();
	}
}

?>